﻿
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using Utils;
using Settings;
namespace PanasonicWarranty.DAL
{
    public partial class DBSmsMoWaiting
    {
        //// Since this class provides only static methods, make the default constructor private to prevent
        //// instances from being created with "new DBSmsMoWaiting()"
        private DBSmsMoWaiting() { }
        
        public static bool Create(Guid MoGuid, string Subs, string Message, string ShortCode, DateTime? ReceivedTime, string Status, int? OperatorID, Guid? SmsInGUID, int? CooperateID)
		{
            try
            {
                using (SqlConnection conn = new SqlConnection(CommonSetting.ConnectionString))
                {
                    int result = SqlHelper.ExecuteNonQuery(conn, "sp_SmsMoWaiting_Insert", MoGuid, Subs, Message, ShortCode, ReceivedTime, Status, OperatorID, SmsInGUID, CooperateID);
                    return (result > 0);
                }
            }catch(Exception ex){
                throw ex;
            }
		}

		public static bool Update(Guid MoGuid, string Subs, string Message, string ShortCode, DateTime? ReceivedTime, string Status, int? OperatorID, Guid? SmsInGUID, int? CooperateID)
		{
            try
            {
                using (SqlConnection conn = new SqlConnection(CommonSetting.ConnectionString))
                {
                    int result = SqlHelper.ExecuteNonQuery(conn, "sp_SmsMoWaiting_Update", MoGuid, Subs, Message, ShortCode, ReceivedTime, Status, OperatorID, SmsInGUID, CooperateID);
                    return (result > 0);
                }
            }catch(Exception ex){
                throw ex;
            }
		}

		public static bool Delete(Guid MoGuid)
		{
            try
            {
                using (SqlConnection conn = new SqlConnection(CommonSetting.ConnectionString))
                {
                    int result = SqlHelper.ExecuteNonQuery(conn, "sp_SmsMoWaiting_Delete", MoGuid);
                    return (result > 0);
                }
            }catch(Exception ex){
                throw ex;
            }
		}

        public static SqlDataReader GetAll()
        {
            try
            {
                return SqlHelper.ExecuteReader(CommonSetting.ConnectionString, CommandType.StoredProcedure,"sp_SmsMoWaiting_GetByAll");
            }catch(Exception ex){
                throw ex;
            }
        }

        public static SqlDataReader GetByKey(Guid MoGuid)
        {
            try
            {
                return SqlHelper.ExecuteReader(CommonSetting.ConnectionString, "sp_SmsMoWaiting_GetById", MoGuid);
            }catch(Exception ex){
                throw ex;
            }
        }

        public static SqlDataReader GetByTop(string top, string where, string order)
        {
            try
            {
                return SqlHelper.ExecuteReader(CommonSetting.ConnectionString, "sp_SmsMoWaiting_GetByTop", top, where, order);
            }catch(Exception ex){
                throw ex;
            }
        }
	}
}
